Prevents navigation stalls from clock changes#3406
Merged
Conversation
Switches from `DateTime.Now` to `Stopwatch.GetTimestamp()` for measuring time between navigations. This ensures that device clock or timezone changes do not incorrectly inflate navigation delays, which previously caused navigation to appear frozen (issue #3405).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Updates the internal mechanism for tracking the last navigation time within
PageNavigationService. ReplacesDateTime.NowwithStopwatch.GetTimestamp()to ensure navigation delay calculations are based on a monotonic, high-resolution timer. This change introduces a new helper method,GetRemainingNavigationDelay, which robustly handles scenarios where the device clock might move backward (e.g., due to timezone changes). Previously, a backward clock change could lead to an excessively large calculated delay, causing subsequent navigations to appear frozen. The updated logic caps this delay at the configured minimum, preventing such stalls.Bugs Fixed
API Changes
Added:
internal static TimeSpan MinTimeBetweenNavigationsinternal static TimeSpan GetRemainingNavigationDelay(long lastNavigateTimestamp, long currentTimestamp)Behavioral Changes
Applications using Prism.Maui will no longer experience navigation freezes or stalls immediately following a device clock or timezone change that results in the system time moving backward. Navigation will remain responsive and adhere to the minimum navigation delay.
PR Checklist